# 第一阶段：构建二进制文件
FROM golang:1.20 AS builder

RUN go env -w GO111MODULE=on

RUN go env -w GOPROXY=https://goproxy.cn,direct

WORKDIR /go/src/micro/first

#RUN go mod init micro/first
#
#RUN go mod tidy

COPY go.mod .
COPY go.sum .

RUN go mod download

COPY . .

#RUN go build -o ./service/user/user ./service/user/main.go
#RUN go build -o ./service/house/house ./service/house/main.go
#RUN go build -o ./service/order/order ./service/order/main.go
#RUN go build -o ./service/pay/pay ./service/pay/main.go
#RUN go build -o ./service/es/es ./service/es/main.go
WORKDIR /go/src/micro/first/web

RUN go build -o /go/src/micro/first/web/house_web ./main.go

CMD ["./house_web"]

# 第二阶段：构建最终图像
#FROM alpine:latest

#RUN apk --no-cache add ca-certificates

#WORKDIR /go/src/micro/first/web

#COPY --from=builder /go/src/micro/first/service/user/user ./service/user/user
#COPY --from=builder /go/src/micro/first/service/house/house ./service/house/house
#COPY --from=builder /go/src/micro/first/service/order/order ./service/order/order
#COPY --from=builder /go/src/micro/first/service/pay/pay ./service/pay/pay
#COPY --from=builder /go/src/micro/first/service/es/es ./service/es/es
#COPY --from=builder /go/src/micro/first/web/house_web house_web

#CMD ["./service/user/user"]
#CMD ["./service/house/house"]
#CMD ["./service/order/order"]
#CMD ["./service/pay/pay"]

#WORKDIR /go/src/micro/first/web

#CMD ["./house_web"]

EXPOSE 8888